﻿using CardPlay.Model.ActionModel;
using CardPlay.Model.CardModel;
using CardPlay.Model.GameModel;
using CardPlay.Model.GameModel.Actions;

namespace CardPlay.DemoPack.Games.KlondikeVariants
{
    [Game("BA3D6915-A424-4D2F-83E7-6B0E4977529F", LevelOfDifficulty.Medium, LevelOfSkill.MostlySkill, DurationOfPlay.Within5To10Minutes, NumberOfDecks = 2, Family = FamilyName)]
    public class Giant : Klondike
    {
        public Giant()
        {
            MaximumDeals = 1;
            TotalDecks = 2;
            TotalFoundations = 8;
            TotalTableaus = 8;
        }

        protected override void PrepareDealScript(DealScript script)
        {
            script.DealCardToEach(NamesOfTableaus);
            script.DealRemainingFaceDownTo(Stock);
        }

        protected override IAction QueryActionAt(PartLocation location)
        {
            var card = CardAt(location);
            if (card == null) return null;

            return location.Matches(Stock) && location.Index == this[Stock].TopIndex
                ? new DealOutTableauAction(this, location) { TargetPattern = AnyTableau }
                : base.QueryActionAt(location);
        }

        protected override bool AllowedToBuildEmptyTableau(MovePileAction action)
        {
            return action.PileBeingMoved.BottomCard.Rank != FoundationBaseRank;
        }
    }
}